import { Meta, ArgsTable, Canvas, Story, Markdown } from '@storybook/addon-docs';
import { useArgs } from '@storybook/client-api';
import { PALETTE } from '@zendeskgarden/react-theming';
import { ColorPicker } from '@zendeskgarden/react-colorpickers';
import README from '../README.md';

<Meta
  title="Packages/Colorpickers/ColorPicker"
  component={ColorPicker}
  parameters={{
    design: {
      allowFullscreen: true,
      type: 'figma',
      url: 'https://www.figma.com/file/6g87L4FdKZTA3knt3Rsfdx/Garden?node-id=2178%3A344'
    }
  }}
/>

# API

<ArgsTable />

# Demo

## Uncontrolled

<Canvas>
  <Story name="Uncontrolled" argTypes={{ color: { control: false } }}>
    {args => <ColorPicker {...args} />}
  </Story>
</Canvas>

## Controlled

<Canvas>
  <Story
    name="Controlled"
    args={{ color: PALETTE.blue[600] }}
    argTypes={{ defaultColor: { control: false } }}
  >
    {args => {
      const updateArgs = useArgs()[1];
      const handleChange = color => updateArgs({ color });
      return <ColorPicker {...args} onChange={handleChange} />;
    }}
  </Story>
</Canvas>

<Markdown>{README}</Markdown>
